package llm

import "strings"

type ChatSession struct {
    History []string
    Persona string
}

func NewSession(persona string) *ChatSession {
    return &ChatSession{
        History: []string{},
        Persona: persona,
    }
}

func (s *ChatSession) BuildPrompt(input string) string {
    var builder strings.Builder
    builder.WriteString(s.Persona + "\n\n")

    for _, h := range s.History {
        builder.WriteString(h + "\n")
    }

    builder.WriteString("使用者: " + input + "\n助手:")
    return builder.String()
}

func (s *ChatSession) Append(userInput, response string) {
    s.History = append(s.History, "使用者: "+userInput, "助手: "+response)
}